function getNowFormatDate() {
    var date = new Date();
    var sign1 = "-";
    var sign2 = ":";
    var year = date.getFullYear() // 年
    var month = date.getMonth() + 1; // 月
    var day  = date.getDate(); // 日
    var hour = date.getHours(); // 时
    var minutes = date.getMinutes(); // 分
    var seconds = date.getSeconds() //秒

    // 给一位数数据前面加 “0”
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (day >= 0 && day <= 9) {
        day = "0" + day;
    }
    if (hour >= 0 && hour <= 9) {
        hour = "0" + hour;
    }
    if (minutes >= 0 && minutes <= 9) {
        minutes = "0" + minutes;
    }
    if (seconds >= 0 && seconds <= 9) {
        seconds = "0" + seconds;
    }
    var currentdate = year + sign1 + month + sign1 + day + " " + hour + sign2 + minutes + sign2 + seconds + " " ;
    return currentdate;
}
function creatUser() {
    var user =" <tr>" +
        "<td>"+$('[name=name]').val()+"</td>" +
        "<td>"+getNowFormatDate()+"</td>" +
        "<td>"+$('[name=signature]').val()+"</td>" +
        "<td>" +
        "<button class=\"layui-btn layui-btn-warm\">删除</button><button class=\"layui-btn layui-btn-normal\">修改</button>" +
        "</td>" +
        "</tr>"
    return user;
}
function creatChangeUser() {
    var user =
        "<td>"+$('[name=name]').val()+"</td>" +
        "<td>"+getNowFormatDate()+"</td>" +
        "<td>"+$('[name=signature]').val()+"</td>" +
        "<td>" +
        "<button class=\"layui-btn layui-btn-warm\">删除</button> <button class=\"layui-btn layui-btn-normal\">修改</button>" +
        "</td>" ;

    return user;
}
function clearFrom() {
    is_add=true;
    $('#userInfo').text('添加会员')
    $('[type=reset]').trigger('click');
}
// 中文字两个字节
$.validator.addMethod("checkName", function(value, element, param) {
    var users = $('tbody').find('tr');
    var back = true;
    var check =true;
    if (!is_add){
        check= value!= this_tr.find('td').eq(0).text()
    }
    users.each(function () {
            if ( $(this).find('td').eq(0).text()==value && check ){
                back =  false;
            }
        })


    return back;
}, $.validator.format("请确保输入的值在{0}-{1}个字节之间(一个中文字算2个字节)"));